package org.jeecg.modules.demo.zhengchai.budget.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.demo.zhengchai.budget.entity.Budget;
import org.jeecg.modules.demo.zhengchai.budget.mapper.BudgetMapper;
import org.springframework.stereotype.Service;

@Service
public class BudgetServiceImpl extends ServiceImpl<BudgetMapper, Budget> implements BudgetService {
    @Override
    public boolean addBudget(Budget budget) {
        return save(budget);
    }

    @Override
    public Budget getBudgetById(Long id) {
        return getById(id);
    }

    @Override
    public boolean updateBudget(Budget budget) {
        return updateById(budget);
    }

    @Override
    public boolean deleteBudgetById(Long id) {
        return removeById(id);
    }

    private final HttpClientService httpClientService;

    public BudgetServiceImpl() {
        this.httpClientService = new HttpClientService();
    }

    public void makeHttpRequest() {
        httpClientService.sendGetRequest("http://example.com/api")
                .thenAccept(response -> {
                    System.out.println("GET Response: " + response);
                });

        String json = "{\"key\": \"value\"}";
        httpClientService.sendPostRequest("http://example.com/api", json)
                .thenAccept(response -> {
                    System.out.println("POST Response: " + response);
                });
    }
}